import lodash from 'lodash'

 const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11]

//  let newArr = []
// for(let i = 0; i <= arr.length; i+=3){
//     if(arr[i]){
//         newArr.push(arr.slice(i,i+3))
//     }
// }
// console.log(newArr);
const chunk = lodash.chunk(arr,3)   // [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10 ] ] 平均分割成三份，剩下不够三份为一个



const arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,[[111,112],[222,333]]]
const flat = lodash.flattenDeep(arr1)
console.log(flat);


const color = ['red','yellow','blue']
const size = ['大','小','中']
const result = color.reduce((previousValue,currentValue)=>{
    let newArr = []
    size.forEach(item=>{
        newArr.push([{color:currentValue,size:item}])
    })
    previousValue.push(newArr)
    return previousValue
},[[]]).filter(item=>item.length != 0) 
console.log(result);


export default {
    chunk
}
